package Control;

import java.awt.Color;

import Miscellaneous.Size;

import UserInterface.*;
import Control.LCPDConverterSettings.LCPDCouplingMode;
import DriverInterface.LCPDDriverInterface;
/**
 * This class initialize every thing and starts the user and driverinterface thread
 * 
 * @author kurmt1@bfh.ch, woodr1@bfh.ch, eichs2@bfh.ch
 * @version 1.0
 */
public class LCPDControl {
	private LCPDData SampleData;

	private LCPDDriverInterface DriverInterface;

	private LCPDConverterSettings ConverterSettings;

	private LCPDUserInterface UserInterface;
	private LCPDGraphicSettings GraphicSettings;
	private LCPDUserInterfaceFFT UserInterfaceFFT;

	private Thread DriverInterfaceThread, UserInterfaceThread;

	private static LCPDControl Control;
	public LCPDControl ()
	{
		// make initial settings
		ConverterSettings = new LCPDConverterSettings();
		ConverterSettings.setFFTMode(false);
		ConverterSettings.setMultiplicator(0, 1);
		ConverterSettings.setMultiplicator(1, 1);
		ConverterSettings.setSampleRate(100000);
		ConverterSettings.setBufferSize(50);
		ConverterSettings.setTotalTime((float) 0.02);
		ConverterSettings.setMaxVoltage(0, 2);
		ConverterSettings.setMaxVoltage(1, 2);
		ConverterSettings.setDisplayTime((float) 0.02);
		ConverterSettings.setTriggerMode(LCPDConverterSettings.LCPDTriggerMode.Auto);
		ConverterSettings.setNewData(true);
		ConverterSettings.setCouplingMode(0, LCPDCouplingMode.DC);
		ConverterSettings.setCouplingMode(1, LCPDCouplingMode.DC);
		ConverterSettings.setRun(true);
		SampleData = new LCPDData(ConverterSettings);
		GraphicSettings=new LCPDGraphicSettings();
		GraphicSettings.setDisplayChannel(0, true);
		GraphicSettings.setDisplayChannel(1, true);
		GraphicSettings.setChannelColor(0, new Color(255,0,0));
		GraphicSettings.setChannelColor(1, new Color(0,255,0));
		// crate Objects of Type Driver- and UserInterface
		DriverInterface = new LCPDDriverInterface(SampleData, ConverterSettings,this);
		UserInterface = new LCPDUserInterface(SampleData, ConverterSettings,GraphicSettings,this);

		DriverInterfaceThread = new Thread(DriverInterface);
		UserInterfaceThread = new Thread(UserInterface);
		// start both threads
		DriverInterfaceThread.start();
		UserInterfaceThread.start();
	}
	public static void main(String[] args) {
		Control = new LCPDControl();
	}
	// stop threads
	public void Stop()
	{
		DriverInterfaceThread.interrupt();
		UserInterfaceThread.interrupt();
	}
	public void getDisplaySettings() {
	}

}
